USE yalan
--additional fields for payables_account
ALTER TABLE payables_account ADD lTaxable BIT, lEWT BIT
ALTER TABLE payables_account ADD cTaxable VARCHAR (3) NOT NULL, cEWT VARCHAR (3) NOT NULL
ALTER TABLE payables ADD cTaxType VARCHAR (15) NULL

ALTER TABLE payables_account ADD CONSTRAINT [df_payables_account_cTaxable] DEFAULT ('NO') FOR cTaxable
ALTER TABLE payables_account ADD CONSTRAINT [df_payables_account_cEWT] DEFAULT ('NO') FOR cEWT

ALTER TABLE payables_account ADD CONSTRAINT [df_payables_account_lTaxable] DEFAULT (0) FOR [lTaxable]
ALTER TABLE payables_account ADD CONSTRAINT [df_payables_account_lEWT] DEFAULT (0) FOR [lEWT]

--additional fields for payables
ALTER TABLE payables ADD nEWTBase NUMERIC (18,2) NULL, nEWTRate NUMERIC (18,2) NULL, nEWT NUMERIC (18,2) NULL,nTaxableBase NUMERIC(18,2),nTaxCode VARCHAR (20) NULL 

ALTER TABLE [dbo].[payables] ADD  CONSTRAINT [DF_payables_nEWT]  DEFAULT (0) FOR [nEWT]
ALTER TABLE [dbo].[payables] ADD  CONSTRAINT [DF_payables_nTaxableBase]  DEFAULT (0) FOR [nTaxableBase]
ALTER TABLE [dbo].[payables] ADD  CONSTRAINT [DF_payables_nEWTBase]  DEFAULT (0) FOR [nEWTBase]
ALTER TABLE [dbo].[payables] ADD  CONSTRAINT [DF_payables_nEWTRate]  DEFAULT (0) FOR [nEWTRate]

--additional fields for wrr
ALTER TABLE wrr ADD nTaxCode VARCHAR (20) NULl
ALTER TABLE wrr ADD nVAT NUMERIC (18,2) NULL, nEWTRate NUMERIC (18,2) NULL, nTaxableBase NUMERIC(18,2)

ALTER TABLE [dbo].[wrr] ADD  CONSTRAINT [DF_wrr_nVAT]  DEFAULT (0) FOR [nVAT]
ALTER TABLE [dbo].[wrr] ADD  CONSTRAINT [DF_wrr_nTaxableBase]  DEFAULT (0) FOR [nTaxableBase]

--insert tax type to parameter_user
INSERT INTO parameter_user cCompanyID,cType,cParamName,cModule,cDesc,cValue,nOrder
VALUES '100-00','TAXTYPE','VAT','WRR','VAT','VAT',1

INSERT INTO parameter_user cCompanyID,cType,cParamName,cModule,cDesc,cValue,nOrder
VALUES '100-00','TAXTYPE','ZERO-RATE','WRR','ZERO-RATE','ZERO-RATE',2

INSERT INTO parameter_user cCompanyID,cType,cParamName,cModule,cDesc,cValue,nOrder
VALUES '100-00','TAXTYPE','VAT EXEMPT','WRR','VAT EXEMPT','VAT EXEMPT',3

INSERT INTO parameter_user cCompanyID,cType,cParamName,cModule,cDesc,cValue,nOrder
VALUES '100-00','TAXTYPE','NON-VAT','WRR','NON-VAT','NON-VAT',4

